package com.imooc.SmartChargeStation.demo;

import com.imooc.SmartChargeStation.demo.netty.NettyServer;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * author: zpy
 * description: Netty启动类
 * date: 2025/8/20
 */
/*
    Netty启动的方式有几种？分别怎么理解？
    1.使用接口CommandLineRunner
    2.使用@PostConstruct注解

 */
//方式一：

    @SpringBootApplication
    @EnableAsync
    public class NettyApplication {
        public static void main(String[] args) {
            SpringApplication.run(NettyApplication.class, args);
            System.out.println("SpringBoot Start....");
        }

        // 无自动执行的Netty启动逻辑
    }


//// 方式二：

//        @SpringBootApplication
//        @EnableAsync // 启用异步方法支持
//        public class NettyApplication implements CommandLineRunner {
//        public static void main(String[] args) {
//            SpringApplication.run(NettyApplication.class, args);
//            System.out.println("SpringBoot Start....");
//        }
//
//        // 异步执行Netty启动
//        @Async
//        @Override
//        public void run(String... args) throws Exception {
//            NettyServer server = new NettyServer(1919);
//            server.start(); // 启动Netty服务器
//        }
//    }
